package com.jiyongjun.component.exception;

import lombok.Getter;

/**
 * <h2></h2>
 * <h3>描述：</h3>
 *
 * @author yongjun.jyj
 * @since 2022/6/13 15:10
 */
@Getter
public class AbstractRuntimeException extends RuntimeException {
    protected final String msgCode;
    /** 异常携带的其他信息，会记录到日志中 */
    protected Object payload;

    public AbstractRuntimeException(String msgInfo) {
        this(null, msgInfo, null);
    }

    public AbstractRuntimeException(String msgCode, String msgInfo) {
        this(msgCode, msgInfo, null);
    }

    public AbstractRuntimeException(String msgCode, String msgInfo, Object payload) {
        super(msgInfo);
        this.msgCode = msgCode;
        this.payload = payload;
    }

    public AbstractRuntimeException(String msgCode, String msgInfo, Throwable cause) {
        this(msgCode, msgInfo, cause, null);
    }

    public AbstractRuntimeException(String msgCode, String msgInfo, Throwable cause, Object payload) {
        super(msgInfo, cause);
        this.msgCode = msgCode;
        this.payload = payload;
    }

}
